//
//  AIFPassportRegisterManager.m
//  PywSdk
//
//  Created by smallwave on 16/8/5.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFPassportRegisterManager.h"
#import "PywPlatformMain.h"
#import "PywRSAUtil.h"

@implementation AIFPassportRegisterManager

NSString *const PassportRegister_PASSPORT = @"passport";
NSString *const PassportRegister_PASSWORD = @"password";
NSString *const PassportRegister_TID = @"tid";
NSString *const PassportRegister_GAMEID = @"gameid";
NSString *const PassportRegister_SMSTYPE = @"smstype";
NSString *const PassportRegister_ISCHECKSMSCODE = @"is_check_smscode";
NSString *const PassportRegister_SIGN = @"sign";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_PASSPORTREGISTER;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}

#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    
    NSString * tid = [PywAppInfo sharedAppInfo].tid;
    NSString * gameId = [PywAppInfo sharedAppInfo].gameId;
    
    NSString * passport = self.passport;
    NSString * password = [PywRSAUtil encryptString:self.password];
    NSString * smstype = self.smsType;
    NSString * is_check_smscode = self.is_check_smscode;
    
    NSString * apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    NSString * sign = [PywCipherUtils md5:[NSString stringWithFormat:@"%@%@%@",passport,smstype,apiSecret2]];
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:tid forKey:PassportRegister_TID];
    [param setObject:gameId forKey:PassportRegister_GAMEID];
    [param setObject:passport forKey:PassportRegister_PASSPORT];
    [param setObject:password forKey:PassportRegister_PASSWORD];
    [param setObject:smstype forKey:PassportRegister_SMSTYPE];
    [param setObject:is_check_smscode forKey:PassportRegister_ISCHECKSMSCODE];
    [param setObject:sign forKey:PassportRegister_SIGN];
    return param;
}

#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}

@end
